<?php
// menu activate page
require_once 'control/common/teamstats/divisions/form.php';
require_once 'view/adm/teamstats/divisions.edit.php';
require_once 'view/adm/teamstats/divisions.index.php';

class DivisionsActivatePage extends PageController {

	var $form;
	var $view;

    function DivisionsActivatePage() {
        parent::PageController();
        $this->form =& new DivisionsFormController();
        $this->registerOnLoadListener(new Delegate($this, 'load'));
        $this->addChild('DivisionsForm', $this->form);
        $this->setDefaultChild('DivisionsForm');

        $this->view =& new DivisionsListView('/adm/teamstats/divisions.index.html');
        $this->setDefaultView($this->view);

        $this->addView('success', WACT_DEFAULT_VIEW);
        $this->addView('notfound', WACT_DEFAULT_VIEW);
        $this->addView('index', new Handle('RedirectView', array('/')));


        $this->registerOnActivateListener(new Delegate($this, 'guard'));
     }

     function guard(&$source, &$request, &$responseModel) {
      if (!$request->hasParameter('divisionID')) {
            return 'notfound';
        }
     }

     function load(&$source, &$request, &$responseModel) {
        //print "Trying to activate...";
        //return 'success';
     	$this->form->load($source, $request, $responseModel);
        $title = $responseModel->get('divisionName');
     	$this->form->enable($source, $request, $responseModel);
     	$responseModel->set('msg','The division '.$title.' has been enabled!');
     	return 'index';
     }
}

?>